import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'

// 路由映射
const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

// Vue2创建路由实例对象
// const router = new VueRouter({
//   mode: 'hash/history',
//   routes: routes
// })

// Vue3创建路由实例对象
const router = createRouter({
  // 设置路由的模式：hash/history
  // history: createWebHistory(),
  history: createWebHashHistory(),
  routes
})

export default router
